export default {
  name: "abnormalRecord",
  components: {
    tab: () => import("../../../component/tab/index.vue"),
    breakAppoint: () => import("./breakAppoint/index.vue"), // 爽约异常处理
    reexamine: () => import("./reexamine/index.vue"), // 复试异常处理
    employ: () => import("./employ/index.vue"), // 录取异常处理
    entry: () => import("./entry/index.vue"), // 入职异常处理
    dimission: () => import("./dimission/index.vue"), // 期内离职异常处理
  },
  data() {
    return {
      options: [{
          val: '1',
          name: "爽约异常",
		  totalnum:0
        },
        {
          val: '2',
          name: "复试异常",
		  totalnum:0
        },
        {
          val: '3',
          name: "录取异常",
		  totalnum:0
        },
        {
          val: '4',
          name: "入职异常",
		  totalnum:0
        },
        {
          val: '5',
          name: "期内离职异常",
		  totalnum:0
        }
      ],
      type: "1",
      title: "爽约异常",
      tableData: [],
      total: 0,
      url: "",
    };
  },
  created() {
	  console.log(this.$route.params);
    this.companyid = this.$route.params.companyid;
    this.total = this.$route.params.params;
  },
  methods: {
    goBack() {
      // this.$router.go(-1);
      this.$router.push({
        name: "employmentList"
      })
    },
    handleClick(item) {
      this.type = item.val;
      this.title = item.name
    },
    // 导出
    exportData(val) {
      let form = {
        companyid: this.companyid,
        starttime: "",
        endtime: "",
        type: ""
      }
      switch (val) {
        case '1':
          this.url = "/app/v1/platform/statistic/breakInterviewListOut";
          form.type = '1';
          break;
        case '2':
          this.url = "/app/v1/platform/statistic/reexamineExceptionListOut";
          break;
        case '3':
          this.url = "/app/v1/platform/statistic/admitExceptionListOut";
          break;
        case '4':
          this.url = "/app/v1/platform/statistic/entryExceptionListOut";
          form.type = '2';
          break;
        default:
          this.url = "/app/v1/platform/statistic/leaveExceptionListOut";
          form.type = '2';
          break;
      }
      this.$axios({
        method: 'post',
        url: this.url,
        data: form,
        responseType: 'blob'
      }).then(res => {
		  console.log(res);
        this.download(res)
      }).catch((error) => {
        this.$message({
          message: '导出失败',
          type: 'error'
        });
      })
    },
    download(res) {
      if (!res) {
        return
      }
      let bob = new Blob([res.data]);
      let fileName = (res.headers['content-disposition']).split('=')[1];
      fileName = decodeURI(fileName)
      let url = window.URL.createObjectURL(bob)
      let link = document.createElement('a')
      link.style.display = 'none'
      link.href = url
      link.setAttribute('download', fileName)
      document.body.appendChild(link)
      link.click()
    }
  }
};